import sys,time
import os
if os.getenv('AG_ENV_PYTHON_PATH') is None:
    ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) + os.sep
else:
    ROOT_DIR = os.getcwd() + os.sep
    # ROOT_DIR = WORK_DIR + "ag_art" + os.sep
parent_dir = os.path.dirname(ROOT_DIR)
import importlib.util
predict6635job_path = parent_dir+'/Predict_6635Job.py'
spec = importlib.util.spec_from_file_location('Predict_6635Job', predict6635job_path)
predict6635job_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(predict6635job_module)
Predict_6635Job = predict6635job_module.Predict_6635Job
# from Predict_6635Job import Predict_6635Job

def main(lg_no,start_date,end_date):
    table_1 = []
    try:
        start_date = str(start_date)
        end_date = str(end_date)
        success_tmp = True
        msg = ''
        timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    except Exception as e:
        success_tmp = False
        msg = f'invalid_parameter_type--{str(e)}'
        timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    if success_tmp:
        table_1 = Predict_6635Job(p_lg_no=lg_no, p_start_date=start_date, p_end_date=end_date).execute()
        timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
        success_tmp = True
    success = success_tmp
    message = msg

    return success, message, timestamp, table_1
if __name__ == '__main__':
    lg_no = 'LG2'
    start_date = '20240601'
    end_date = '20240630'

    success, message, timestamp, table_1 = main(lg_no, start_date, end_date)
    print(success, message, timestamp, table_1)
